package sprite;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.MouseEvent;


public class Tower extends Sprite{
	
	private int power = 0;
	private int type = 0; 
	private int id = -1;
	private int radius = 100;
	private Rectangle attackRectangle = new Rectangle();
	private boolean showRadius = false;
	private boolean attack = false;
	private int speed = 50;
	
	public Tower() {
		
	}
	public void setPower(int power) {this.power = power;}
	public int getPower() {return power;}
	public void setType(int type) {this.type = type;}
	public int getType() {return type;}
	public void setId(int id) {this.id = id;}
	public int getId() {return id;}
	
	public int handleMousePressed(MouseEvent e, int mouseX, int mouseY) {
		
		if (this.getRect().contains(new Point(mouseX, mouseY))) {
			showRadius = true;
			return this.getId();
		}
		else {
			showRadius = false;
			return -1;
		}
	}
	public void drawOn(Graphics g) {
		super.drawOn(g);
		if (showRadius) {
			Color currentColor = g.getColor();
			Color seeThroughGray = new Color(179,179,179,179);
			g.setColor(seeThroughGray);
			g.fillRect(this.getX() + this.getWidth()/2 - this.radius/2, 
					this.getY() + this.getHeight()/2 - this.radius/2, this.radius, this.radius);
			g.setColor(currentColor);
		}
	}
	public void setPosition(int x, int y) {
		super.setPosition(x, y);
		this.attackRectangle.setLocation(this.getX() + this.getWidth()/2 - this.radius/2, 
				this.getY() + this.getHeight()/2 - this.radius/2);
	}
	public void setRadius(int radius) {
		this.radius = radius;
		this.attackRectangle.setSize(this.radius, this.radius);
	}
	public int getRadius() {
		return radius;
	}
	public void setShowRadius(boolean set) {
		this.showRadius = set;
	}
	public void setSpeed(int speed) {
		this.speed = speed;
	}
	public int getSpeed() {
		return speed;
	}
	public void setAttack(boolean attack) {
		this.attack = attack;
	}
	public boolean isAttack() {
		return attack;
	}
	public Rectangle getAttackRectangle() {
		return this.attackRectangle;
	}
	
}
